package com.atguigu.springboot.mapper;

import com.atguigu.springboot.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author : wenchao.long
 * @date : Created in 2020/11/26 10:17 周四
 * @description :
 */
public interface EmployeeMapper {
    /**
     * 通过id查询
     *
     * @param id id
     * @return Employee
     */
    Employee getById(@Param("id") Integer id);

    /**
     * 修改
     *
     * @param employee employee
     */
    void update(Employee employee);

    /**
     * 插入
     *
     * @param employee employee
     */
    @Options(useGeneratedKeys = true)
    @Insert("INSERT INTO `employee`(last_name,email,gender,department_id) VALUE (#{lastName},#{email},#{gender},#{departmentId})")
    void insert(Employee employee);

    /**
     * 删除
     *
     * @param id id
     */
    void deleteById(@Param("id") Integer id);

    /**
     * 名称查询
     * @param lastName lastName
     * @return Employee
     */
    @Select("select * from `employee` where last_name=#{lastName}")
    Employee getByName(String lastName);
}
